/*
 * main.cpp
 *
 *  Created on: Feb 3, 2010
 *      Author: Jamie LaPointe
 *
 *       Notes: Gives an example of using a mutex to protect a critical section (e.g. access
 *              to shared memory) of code.  The original dot product was written in C and is
 *              from: https://computing.llnl.gov/tutorials/pthreads/#Pthread
 *              This example uses a joinable thread to allow the main thread to wait for
 *              the workers to be done.  This is generally considered bad coding practice.
 *              Example 03Semaphore shows the same example using a detached thread (e.g. non-
 *              joinable) and using semaphores to signal to the main thread when the workers
 *              are finished, this is the preferred method.
 */

#include "ThreadedDotProduct.h"
#include <iostream>
#include <iomanip>

using namespace MutexExample;

using std::cout;
using std::endl;
using std::fixed;
using std::setprecision;

int main()
{
   ThreadedDotProduct * dotProduct = new ThreadedDotProduct();

   cout << fixed;
   cout << setprecision(5);
   cout << "Sum = " << dotProduct->run() << endl;

   delete(dotProduct);

   return 0;
}
